/* eslint-disable @typescript-eslint/indent */
import { AKEnemy, AKRaidBuff, AKCharacter, calculateDps } from './attributes'
import { success, fail } from '../../types'
import { Router } from 'express'

const router = Router()

const DefaultEnemy: AKEnemy = {
  def: 0,
  magicResistance: 0,
  count: 1
}

const DefaultRaidbuff: AKRaidBuff = {
  atk: 0,
  atkpct: 0,
  ats: 0,
  cdr: 0,
  base_atk: 0,
  damage_scale: 0
}

router.get('/:charId/:skillId',
       (req, res) => {
        const ch: AKCharacter = {
          charId: req.params.charId,
          skillId: req.params.skillId,
          options: { cond: true, crit: true }
        }
        console.log(ch)
        try {
          res.send(success(calculateDps(ch, DefaultEnemy, DefaultRaidbuff)))
        } catch (e) {
          res.send(fail(`Error: ${e}`))
        }
       })

router.post('/', (req, res) => {
  console.log(req.body)
  try {
    res.send(success(calculateDps(req.body.char, req.body.enemy, req.body.raidBuff)))  // char, enemy, raidBuff
  } catch (e) {
    res.send(fail(`Error: ${e}`))
  }
})

export default router